package com.gitee.gateway.demo;

import com.gitee.gateway.core.common.VerticleBase;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.json.JsonObject;
import io.vertx.serviceproxy.ServiceBinder;

/**
 * Demo Service Verticle
 */
public class DemoVerticle extends VerticleBase {
    private MessageConsumer<JsonObject> binder;
    private DemoService service;

    @Override
    public void start() throws Exception {
        this.service = DemoService.create(vertx, config());
        this.binder = new ServiceBinder(vertx).setAddress(DemoService.ADDRESS).register(DemoService.class, service);
    }

    @Override
    public void stop() {
        new ServiceBinder(vertx).setAddress(DemoService.ADDRESS).unregister(binder);
        service.close();
    }
}
